package com.quick.develop.flowable.framework.core;

import com.quick.develop.flowable.constant.BpmConstants;
import com.quick.develop.flowable.framework.factory.FlowServiceFactory;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.common.engine.impl.event.FlowableEntityEventImpl;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @author junyuan.liu
 * @description: TODO 任务创建全局监听
 * 后续可作为人员分配监听  任务就无需再挂人员分配监听
 * 不是子流程的情况下考虑是否需要自动完成第一个节点??-需要考虑是否退回？？
 * @date 2022/6/4 14:08
 */
@Component
@Slf4j
public class BpmTaskCreatedListener extends FlowServiceFactory implements FlowableEventListener {

    @Override
    public void onEvent(FlowableEvent flowableEvent) {
        TaskEntityImpl entity = (TaskEntityImpl) ((FlowableEntityEventImpl) flowableEvent).getEntity();
        String description = entity.getDescription();
        if (Objects.equals(description, BpmConstants.CANDIDATE)) {

        }
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }

    @Override
    public boolean isFireOnTransactionLifecycleEvent() {
        return false;
    }

    @Override
    public String getOnTransaction() {
        return null;
    }

}
